/**
 * Created by liuzengrong on 2019/8/16.
 */

import common from './common';
import user from './user';
import exchangeRate from './exchangeRate';
import shippingLanes from './shippingLanes';
import shippingCompany from './shippingCompany';
import port from './port';
import costItems from './costItems';
import item from './item';
import userManage from './userManage';
import role from './role';
import resource from './resource';
import rights from './rights';
import lessee from './lessee';
import namespace from './namespace';
import product from '@/dictionary/product';
import serviceOrder from '@/dictionary/serviceOrder';
import supplierBaseInfo from './supplierBaseInfo';
import supplierOrder from './supplierOrder';
import logisticsOrder from './logisticsOrder';
import cost from './cost';

/**
 * 数据字典
 *
 * @returns {string}
 * @constructor
 */
const Dictionary = {
  /**
   * 获取字段集合
   *
   * @returns {string}
   */
  // eslint-disable-next-line max-len
  getFields: () =>
    common.concat(
      user,
      exchangeRate,
      shippingLanes,
      shippingCompany,
      port,
      costItems,
      userManage,
      role,
      item,
      resource,
      rights,
      lessee,
      namespace,
      product,
      serviceOrder,
      supplierBaseInfo,
      supplierOrder,
      logisticsOrder,
      cost
    ),

  /**
   * 获取符合条件的字段集合
   *
   * @param names
   */
  getFieldsByNames(names: string[]) {
    return this.getFields().filter(field => {
      // eslint-disable-next-line no-restricted-syntax
      for (const name of names) {
        if (name === field.name) {
          return true;
        }
      }
      return false;
    });
  },
};

export default Dictionary;
